package com.example.test.启动线程.线程状态;

public class Task implements Runnable{
    @Override
    public void run() {

        synchronized (this){
            System.out.println(Thread.currentThread().getState());
        }
    }

    public static void main(String[] args) {

        Task task = new Task();

        Thread thread = new Thread(task);

//        System.out.println(thread.getState());
//
//        thread.start();
//
//        System.out.println(thread.getState());

        synchronized (task){
            thread.start();
            System.out.println(thread.getState());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(thread.getState());
        }

    }
}
